﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.AspNet.Membership.OpenAuth;

public partial class Register : Page
{



    protected void Page_Load(object sender, EventArgs e)
    {
      
    }

    protected void Register_Click(object sender, EventArgs e)
    {

        if (IsPostBack)
        {


            ServiceReference.ServiceClient service = new ServiceReference.ServiceClient();
            ServiceReference.Person pers = new ServiceReference.Person();

            pers.fName = fNameTextBox.Text;
            pers.sName = sNameTextBox.Text;
            pers.address = AddressTextBox.Text;
            if (RadioButton1.Checked)
                pers.gender = true;
            else
                pers.gender = false;

            pers.passportNo = PassportTextBox.Text;
            pers.phone = PhoneTextBox.Text;
            //pers = (ServiceReference.Person)service.AddToDatabase(pers);

            ServiceReference.Account acc = new ServiceReference.Account();
            acc.email = EmailTextBox.Text;
            acc.access = 2;
            acc.password = Password.Text;
            acc.username = UserName.Text;
            acc.personId = pers.personId;

            service.createAccount(pers, acc.username, acc.password, acc.email, acc.access);
            service.Close();
        }
        else { 
        }


    }




}